home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / tests / matric.tst < prev    next >
Text File  |  1999-09-16  |  1KB  |  40 lines

  1. Leps=1.d-5;
  2. //tests riccati lyapounov sylvester
  3. //
  4. //   lyapunov
  5. a=rand(3,3);x=rand(3,3);x=x*x';c=a'*x+x*a;
  6. if norm(lyap(a,c,'cont')-x) > Leps then pause,end
  7. c=a'*x*a-x;
  8. if norm(lyap(a,c,'disc')-x) > Leps then pause,end
  9. //
  10. //      sylvester
  11. x=rand(3,2);a=rand(3,3);b=rand(2,2);c=a*x+x*b;
  12. if norm(sylv(a,b,c,'cont')-x) > Leps then pause,end
  13. //      riccati
  14. a=rand(3,3);
  15. b=rand(3,2);
  16. c=rand(3,3);c= c*c';r=rand(2,2);r=r*r'+eye;b=b*inv(r)*b';
  17. x=ricc(a,b,c,'cont');
  18. if norm(a'*x+x*a-x*b*x+c ) > Leps then pause,end
  19. aa=[a -b;-c -a'];
  20. [xx,d]=gschur(eye(6,6),aa,'cont');
  21. xx=xx(:,1:d);
  22. if norm(xx(4:6,:)/xx(1:3,:)-x) > Leps then pause,end
  23. [xx,d]=schur(aa,'cont');xx=xx(:,1:d);
  24. if norm(xx(4:6,:)/xx(1:3,:)-x) > Leps then pause,end
  25. //       discrete time case
  26. f=a;b=rand(3,2);g1=b;g2=r;g=g1/g2*g1';h=c;x=ricc(f,g,h,'disc');
  27. if norm(f'*x*f-(f'*x*g1/(g2+g1'*x*g1))*(g1'*x*f)+h-x) > Leps then pause,end
  28. aa=[eye(3,3) g;0*ones(3,3) f'];
  29. bb=[f 0*ones(3,3);-h eye(3,3)];
  30. [xx,d]=gschur(bb,aa,'disc');xx=xx(:,1:d);
  31. if norm(xx(4:6,:)/xx(1:3,:)-x) > Leps then pause,end
  32. fi=inv(f);
  33. hami=[fi fi*g;h*fi f'+h*fi*g];
  34. [xx,d]=schur(hami,'d');xx=xx(:,1:d);
  35. fit=inv(f');
  36. ham=[f+g*fit*h -g*fit;-fit*h fit];
  37. [uu,d]=schur(ham,'d');
  38. uu=uu(:,1:d);
  39. if norm(uu(4:6,:)/uu(1:3,:)-x) > Leps then pause,end
  40.